<?php
declare (strict_types = 1);

namespace app\api\controller\v1;


use think\facade\Request;
use app\api\service\StatusCode;
use app\api\service\UserToken;
use app\api\model\TodoList as ModelTodoList;
use app\api\validate\TodoList as ValidateTodoList;
use app\api\validate\ParamMustBePostiveInt;
/**
 * 学生端事项管理
 */
class StuTodoList extends Api
{
    /**
     * 
     * 获取所有事项
     */
    public function index()
    {
        $uid =  UserToken::getCurrentUid();
        $job = 1;
        $data = ModelTodoList::getTodoList($uid,$job);
        exit(json_encode($data));
    }

    /**
     * 
     * 新增事项
     */
    public function create()
    {
        $data = Request::post();
        validate(ValidateTodoList::class)->scene('createTodoList')->check($data);
        $data["user_id"] = UserToken::getCurrentUid();
        $data['job'] = 1;
        $success = ModelTodoList::addTodoList($data);
        $this->return_msg(StatusCode::SUCCESS,'新增成功', $success);
    }


}